{include file="index/header" /}
<body>
<div class="panel admin-panel">
  <div class="panel-head"><strong class="icon-reorder"> 内容列表</strong></div>
  <div class="padding border-bottom">  
  <button type="button" class="button border-yellow" onclick="window.location.href='{:url('privilege/add')}'"><span class="icon-plus-square-o"></span> 添加内容</button>
  </div>
  <form method="post" action="" id="listform">
  <table class="table table-hover text-center">
    <tr>
      <th width="10%">ID</th>
      <th width="10%">权限名称</th>
      <th width="10%">权限地址</th>
      <th width="10%">是否显示</th>
      <th width="15%">操作</th>
    </tr>
    {foreach name='data' item='v'}
    <tr>
      <td><input type="checkbox" name="privilege_id[]" value="{$v.privilege_id}" />{$v.privilege_id}</td> 
      <td align="left"><?php echo str_repeat("--",$v['level']*3).$v['privilege_name']; ?></td>
      <td>{$v.controller_name}/{$v.action_name}</td>
      <td>{if $v.privilege_status eq 1}是{else}否{/if}</td>
      <td><div class="button-group">
      <a class="button border-main" href="{:url('privilege/edit',['privilege_id' => $v['privilege_id']])}"><span class="icon-edit"></span> 修改</a>
      <a class="button border-red" href="{:url('privilege/delete',['privilege_id' => $v['privilege_id']])}" onclick="if(confirm('确定删除?')==false)return false;"><span class="icon-trash-o"></span> 删除</a>
      </div></td>
    </tr>
    {/foreach}
  </table>
  <input type="hidden" name="status" value="">
  </form>
</div>
</body></html>
<script>
  //全选
$("#checkall").click(function(){ 
  $("input[name='privilege_id[]']").each(function(){
    if (this.checked) {
      this.checked = false;
    }
    else {
      this.checked = true;
    }
  });
});

//批量删除
function DelSelect(){
  var Checkbox=false;
   $("input[name='privilege_id[]']").each(function(){
    if (this.checked==true) {   
    Checkbox=true;  
    }
  });
  if (Checkbox){
    var t=confirm("您确认要删除选中的内容吗？");
    if (t==false) return false;   
    $('input[name=status]').val('del');
    $("#listform").submit();    
  }
  else{
    alert("请选择您要删除的内容!");
    return false;
  }
}

</script>